package com.bootdo.front.controller;

import com.bootdo.common.utils.OfficeUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/excel")
public class ExcelController {

    @PostMapping("/look")
    public void look(@RequestParam("excelFile") MultipartFile excelFile){
        try {
            Map<String, List<String>> map = OfficeUtils.readExcel(excelFile);
            List<String> list1 = map.get("list1");
            List<String> list2 = map.get("list2");
//      list.removeIf(Objects::isNull);去掉null值
            //去掉空字符串
            list1.removeIf(""::equals);
            list2.removeIf(""::equals);
            //遍历list,查看数据
            int size1 = list1.size();
            for (int i = 0; i < size1; i++) {
                String value = list1.get(i);
                if (!(list2.contains(value))) {
                    System.out.println(value);
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
